package com.suixinsanren.design.observer.demo04;

import java.util.Date;

public class StatisticsDisplay implements DisplayWeatherDate, Observer {

    private double maxTemperature;
    private double minTemperature;
    private double currentTemperature;
    private double humidity;
    private Date date;

    @Override
    public void display() {
        System.out.println(
                "今天是" + date.toString() +
                        "，最高温度：" + maxTemperature + "，最低温度：" + minTemperature + "，" +
                        "当前温度：" + currentTemperature +
                        "，湿度：" + humidity);
    }

    @Override
    public void update(Date date, double maxTemperature, double minTemperature, double currentTemperature, double humidity) {
        this.maxTemperature = maxTemperature;
        this.minTemperature = minTemperature;
        this.currentTemperature = currentTemperature;
        this.humidity = humidity;
        this.date = date;
        display();
    }
}
